#!/usr/bin/perl -w

############################################################
# A small little hook to parse the channel chat for URLs   #
# and make Tinyurls out of them. As requested by cshields. #
############################################################

use URI::Find::Rule;
use WWW::Shorten::TinyURL;
use WWW::Shorten 'TinyURL';

my $nick = $ENV{'HBEV_SENT_BY'};
my $msg = <>;

my @urls = URI::Find::Rule->in($msg,1);
if(@urls){
	foreach $url (@urls){
		if(length($url->as_string) > 79){
			$short_url = makeashorterlink($url->as_string);
			print "msg $nick\'s tiny URL is $short_url\n";
		}
	}
}
